function energy = energyFunction(wf, S)
%ENERGYFUNCTION Summary of this function goes here
%   Detailed explanation goes here


    len = length(wf(1,:)); %La matriz es cuadrada.    
    acum = 0;
    for i = 1:len
        for j=1:len
            acum = acum + wf(i,j)*S(i)*S(j);
        end
    end
    energy = -acum/2;
    
    
    %energy = -0.5*sum(sum(wf*(S*S')));

end

